/*
 * Copyright 2020-2025 the original author or authors.
 * You cannot use this file unless authorized by the author.
 */
package org.ipig.commons.service.dyna;

import lombok.Data;

import javax.tools.SimpleJavaFileObject;
import java.net.URI;
import java.nio.CharBuffer;

/**
 * CustomJavaFileObject
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: CustomJavaFileObject.java 3 2020-01-21 09:36:33Z ts <comchnts@163.com> $$
 * @since 1.0
 */
@Data
public class CustomJavaFileObject extends SimpleJavaFileObject {
    private String charContent;

    public CustomJavaFileObject(Kind kind, String fileName, String charContent) {
        super(URI.create(fileName), kind);
        this.setCharContent(charContent);
    }

    /**
     * Construct a SimpleJavaFileObject of the given kind and with the
     * given URI.
     *
     * @param uri  the URI for this file object
     * @param kind the kind of this file object
     */
    protected CustomJavaFileObject(URI uri, Kind kind) {
        super(uri, kind);
    }

    @Override
    public CharBuffer getCharContent(boolean b) {
        return CharBuffer.wrap(this.getCharContent());
    }
}
